import java.util.*;

public class PaperSelection {
    private final Map<Paper, Student> selections = new HashMap<>();

    public boolean addSelection(Student student, Paper paper) {
        if (selections.containsKey(paper)) {
            return false; // 论文已被选择
        }
        selections.put(paper, student);
        return true;
    }

    public boolean isSelected(Paper paper) {
        return selections.containsKey(paper);
    }

    public Map<Paper, Student> getSelections() {
        return Collections.unmodifiableMap(selections);
    }

    // 支持Visitor模式
    public void accept(Visitor visitor) {
        for (Map.Entry<Paper, Student> entry : selections.entrySet()) {
            visitor.visit(entry.getKey(), entry.getValue());
        }
    }
}    